﻿@using GridViewCustomBinding.Controllers

@model GridViewModel

@Html.DevExpress().GridView(
    settings => {
        settings.Name = "gvCar";
        
        settings.CallbackRouteValues = new {
            Controller = "Home",
            Action = CarControllerAction.Car_Partial
        };
        settings.CustomBindingRouteValuesCollection.Add(
            GridViewOperationType.Paging,
            new {
                Controller = "Home",
                Action = CarControllerAction.Car_Partial_Paging
            }
        );        
        
        settings.KeyFieldName = "id";
        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
        settings.Settings.ShowColumnHeaders = true;
        settings.Settings.ShowFilterRow = true;
        settings.Settings.ShowFilterRowMenu = true;
        settings.Settings.ShowFooter = true;
        settings.Settings.ShowGroupButtons = true;
        settings.Settings.ShowGroupedColumns = true;
        settings.Settings.ShowGroupPanel = true;
        settings.Settings.ShowHeaderFilterButton = true;
        settings.Settings.ShowTitlePanel = true;
        settings.Settings.UseFixedTableLayout = true;

        settings.SettingsBehavior.AllowDragDrop = true;
        settings.SettingsBehavior.AllowFocusedRow = true;
        settings.SettingsBehavior.AllowGroup = true;
        settings.SettingsBehavior.AllowSort = true;
        settings.SettingsBehavior.ColumnResizeMode = ColumnResizeMode.NextColumn;
        settings.SettingsBehavior.ConfirmDelete = true;
        settings.SettingsBehavior.EnableRowHotTrack = true;

        settings.SettingsPager.FirstPageButton.Visible = true;
        settings.SettingsPager.LastPageButton.Visible = true;
        //settings.SettingsPager.PageSize = 50;
        settings.SettingsPager.PageSizeItemSettings.Visible = true;
        settings.SettingsPager.PageSizeItemSettings.Items = new string[] { "10", "20" };

        settings.SettingsCookies.Enabled = true;
        settings.SettingsCookies.CookiesID = settings.Name;
        settings.SettingsCookies.StoreColumnsVisiblePosition = true;
        settings.SettingsCookies.StoreColumnsWidth = true;
        settings.SettingsCookies.StoreFiltering = true;
        settings.SettingsCookies.StoreGroupingAndSorting = true;
        settings.SettingsCookies.StorePaging = true;

        settings.SettingsBehavior.EnableCustomizationWindow = true;
        settings.SettingsPopup.CustomizationWindow.Height = 500;
        settings.SettingsPopup.CustomizationWindow.Width = 250;

        settings.Columns.Add(column => {
            column.FieldName = "id";
            column.ColumnType = MVCxGridViewColumnType.TextBox;});
        settings.Columns.Add(column => {
            column.FieldName = "model";
            column.ColumnType = MVCxGridViewColumnType.TextBox;});
        settings.Columns.Add(column => {
            column.FieldName = "brand";
            column.ColumnType = MVCxGridViewColumnType.TextBox;});
        settings.Columns.Add(column => {
            column.FieldName = "engine.id";
            column.ColumnType = MVCxGridViewColumnType.TextBox;});
        settings.Columns.Add(column => {
            column.FieldName = "engine.brand";
            column.ColumnType = MVCxGridViewColumnType.TextBox;});
        settings.Columns.Add(column => {
            column.FieldName = "engine.model";
            column.ColumnType = MVCxGridViewColumnType.TextBox;});
        settings.Columns.Add(column => {
            column.FieldName = "engine.horsePower";
            column.ColumnType = MVCxGridViewColumnType.TextBox;});
    }).BindToCustomData(Model).GetHtml()